package com.bjsxt.common.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@Component("adminInterceptor")
public class AdminInterceptor extends HandlerInterceptorAdapter
{
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
	{
		HttpSession session = request.getSession();
		Object attribute = session.getAttribute("admin");
		if(attribute!=null)
		{
			return true;
		}
		session.setAttribute("info", "非法访问，请先登录");
		response.sendRedirect(request.getContextPath()+"/adminLogin.htm");
		return false;
	}
}
